package com.openswimsoftware.orm.model.db;

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;

public class ModelDBinterface {
	
	private boolean open = false;
	private SQLiteDatabase db;
	private ModelDBHelper dbHelper;
	private Context context;
	
	public ModelDBinterface(Context context)
	{
		this.context = context;
		this.dbHelper = new ModelDBHelper(this.context);
	}
	
	public void openDB() throws SQLException 
	{
		if (this.open == false)
		{
			db = this.dbHelper.getWritableDatabase();
			this.open = true;
		}
	}
	
	public void closeDB()
	{
		if (this.open == true)
		{
			this.dbHelper.close();
			this.open = false;
		}
	}
	
	public SQLiteDatabase getDB()
	{
		return db;
	}
	
}
